$(document).ready(function (){
    var userstring = sessionStorage.getItem('user');
    var user = JSON.parse(userstring);
    var nickname=user.nickname;
    $('#nickname').text(nickname);

    var sid;
    var pid;

   //根据uid查询地址
    var uid = user.id;
    var addressnow;
    $.get("pc/address/find", {"uid": uid }, function (rs) {
        var pros = rs.result;
        var dl = $("dl[name='u_address']");
        dl.empty();
        dl.append('<dt>寄送到：</dt>');
        for (var i = 0; i < pros.length; i++) {
            var address = pros[i];
            addressnow=address.detailedAddress;
            var addressHtml = "<dd><input type='radio' name='address'  value='" + i + "' " + (i === 0 ? "checked" : "") + " >" +
                    address.detailedAddress+ ' ' + "("+address.sname + " 收 )" + address.phone + "</dd>";
            $(addressHtml).appendTo(dl);
        }
        dl.on('change', 'input[type="radio"][name="address"]', function() {
            var add = $(this).val();
            sid=pros[add].id
    });
    });
    $(document).on("change",'input[type="radio"][name="pay_style"]',function () {
           pid = $(this).val();
    });

});